package com.example.lin.utils;

import org.springframework.stereotype.Component;

/**
 * @author Administrator
 */
@Component
public class ThreadLocalUtil {
    /**
     * 线程变量隔离
     */
    private static final ThreadLocal<String> USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 存储线程变量
     */
    public static void set(String value) {
        USER_THREAD_LOCAL.set(value);
    }

    /**
     * 获取线程变量
     */
    public static String get() {
        return USER_THREAD_LOCAL.get();
    }

    /**
     * 删除线程变量
     */
    public static void remove() {
        USER_THREAD_LOCAL.remove();
    }
}
